翻訳と辞書
Words near each other
・ Exquisite Model of Ware
・ Exquisite rainbowfish
・ Exquisite Sinner
・ Exquisite wrasse
・ EXR
・ ExR
・ EXR (clothing)
・ Exs
・ Expression Atlas
・ Expression cassette
・ Expression cloning
・ Expression index
・ Expression pedal
・ Expression problem
・ Expression quantitative trait loci
Expression templates
・ Expression vector
・ Expression-oriented programming language
・ Expressionism
・ Expressionism (theatre)
・ Expressionist architecture
・ Expressionist dance
・ Expressionist Head
・ Expressionist Master of Santa Chiara
・ Expressionist music
・ Expressions (Chick Corea album)
・ Expressions (Sarah Geronimo album)
・ Expressions Art Gallery
・ Expressions Dance Company
・ Expressions in Chalk Street Painting Festival


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Expression templates : ウィキペディア英語版
Expression templates
Expression templates is a C++ template metaprogramming technique in which templates are used to represent part of an expression. Typically, the template itself represents a particular kind of operation, while the parameters represent the operands to which the operation applies.〔
〕 The expression template can then be evaluated at a later time, or passed to a function. The technique was invented independently by Todd Veldhuizen and David Vandevoorde.〔〔
〕〔

For example, consider a library representing vectors with a class Vec. It is natural to want to overload operator- and operator
*
so you could write Vec x = alpha
*(u - v);
where alpha is a scalar and u and v are Vecs. A naive implementation would have operator- and operator
*
return Vecs. However, then the above expression would mean creating a temporary for u-v then another temporary for alpha times that first temporary, then assigning that to x. Even with the return value optimization this will allocate memory at least twice: once for the temporary u-v and once for the result of the overall expression.
Expression templates delay evaluation so the expression Vec x = alpha
*(u-v);
essentially generates at compile time a new Vec constructor. It is as if this constructor takes a scalar and two Vecs by reference; it allocates the necessary memory and then performs the computation. Thus only one memory allocation is performed.
An example implementation of expression templates is as follows (using the curiously recurring template pattern as is used by Boost.uBLAS):

#include
#include
/
* The template parameter is named 'E' for 'Expression'
*/
template
// A CRTP base class for Vecs with a size and indexing:
class VecExpression
value_type operator = v();
}
}
};
template
class VecDifference : public VecExpression >
value_type operator; }
};

template
class VecScaled : public VecExpression >
Vec::value_type operator = v();

to essentially

_data() = alpha
* (u() - v());

with no temporaries needed and only one pass through each memory block.
== Libraries using Expression templates ==

* Boost uBLAS〔
(【引用サイトリンク】 Boost Basic Linear Algebra Library )

* Eigen〔
(【引用サイトリンク】 Eigen: Lazy Evaluation and Aliasing )


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Expression templates」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.